package interview.eventSystem;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by richard on 6/3/14.
 */
public class MainThread {

    public static void main(String[] args){
        ExecutorService serverSimulator = Executors.newFixedThreadPool(10);
        ExecutorService clientSimulator = Executors.newFixedThreadPool(5);
        Container container = new Container(6,true);
        for(int i=0; i <10 ; i++){
            container.registerServer(new UpperServer(i));

        }
        for(int i=0; i <5 ; i++){
            container.registerClient(new Client(i));
        }
        for(UpperServer upperServer : container.getServerList()){
            serverSimulator.execute(upperServer);
        }
        for(Client client : container.getClientList()){
            clientSimulator.execute(client);

        }

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        serverSimulator.shutdownNow();
        clientSimulator.shutdownNow();

    }
}
